import request from '../utils/request'

/**
 * 后面的每次请求都是需要携带token的
 */
export const findUserList = (current,size,userVo) => {
  return request({
    url: '/user/findUserPage',
    method: 'post',
    params: {
      current,
      size
    },
    data : userVo
  })
}


/**
 * 添加用户
 */
export const saveUser = (user) => {
  return request({
    url: '/user/addUser',
    method: 'post',
    data : user
  })
}

/**
 * 导出用户Excel
 * @param userVo
 */
export function exportUserInfo(userVo) {
  return request({
    url: '/user/excel',
    method: 'post',
    data: userVo,
    responseType: "blob"
  })
}

/**
 * 删除用户
 * @param id
 */
export function deleteUser(id) {
  return request({
    url: '/user/delete',
    method: 'delete',
    params: {
      id
    }
  })
}

/**
 * 用户信息详情
 * @param id
 */
export function userInfoDetail(id) {
  return request({
    url: '/user/edit',
    method: 'post',
    params: {
      id
    }
  })
}

/**
 * 用户登录
 * @param userLogin
 * @returns {AxiosPromise}
 */
export function login(userLogin) {
  return request({
    url: '/user/login',
    method: 'post',
    data: userLogin
  })
}

/**
 * 更新用户信息
 * @param id
 */
export function updateUserInfo(UserEditVO) {
  return request({
    url: '/user/update',
    method: 'post',
    data: UserEditVO
  })
}

/**
 * 角色列表分页查询
 * @param current
 * @param size
 * @param userVo
 * @returns {AxiosPromise}
 */
export const findRolePage = (current,size,roleVo) => {
  return request({
    url: '/role/findRolePage',
    method: 'post',
    params: {
      current,
      size
    },
    data : roleVo
  })
}

/**
 * 用户信息详情
 * @param id
 */
export function roleDetail(id) {
  return request({
    url: '/role/roleDetail',
    method: 'post',
    params: {
      id
    }
  })
}


/**
 * 更新角色信息
 * @param id
 */
export function updateRole(RoleVo) {
  return request({
    url: '/role/updateRole',
    method: 'post',
    data: RoleVo
  })
}

/**
 * 删除角色
 * @param id
 */
export function deleteRole(id) {
  return request({
    url: '/role/deleteRole',
    method: 'delete',
    params: {
      id
    }
  })
}

/**
 * 添加用户
 */
export const addRole = (Role) => {
  return request({
    url: '/role/addRole',
    method: 'post',
    data : Role
  })
}

/**
 * 绑定用户角色
 */
export const bindUserRole = (UserRole) => {
  return request({
    url: '/user/bindUserRole',
    method: 'post',
    data : UserRole
  })
}

/**
 * 根据用户id查询角色
 * @param id
 * @returns {AxiosPromise}
 */
export const getRoleByUserId = (id) => {
  return request({
    url: '/role/getRoleByUserId',
    method: 'post',
    params: {
      id
    }
  })
}

/**
 * 菜单列表
 * @param UserKeyWord
 * @returns {AxiosPromise}
 */
export const queryMenuList = (UserKeyWord) => {
  return request({
    url: '/menu/queryMenuList',
    method: 'post',
    data : UserKeyWord
  })
}

/**
 * 菜单权限授权
 * @param roleMenu
 * @returns {AxiosPromise}
 */
export const menuAuth = (roleMenu) => {
  return request({
    url: '/role/menuAuth',
    method: 'post',
    data : roleMenu
  })
}

/**
 * 根据角色ID获取菜单列表
 * @param id
 * @returns {AxiosPromise}
 */
export const getMenuByRoleId = (id) => {
  return request({
    url: '/menu/getMenuByRoleId',
    method: 'post',
    params: {
      id
    }
  })
}

/**
 * 添加菜单
 */
export const addMenu = (Menu) => {
  return request({
    url: '/menu/addMenu',
    method: 'post',
    data : Menu
  })
}

/**
 * 菜单信息详情
 * @param id
 */
export function edit(id) {
  return request({
    url: '/menu/edit',
    method: 'post',
    params: {
      id
    }
  })
}

/**
 * 更新菜单信息
 * @param id
 */
export function updataMenu(Menu) {
  return request({
    url: '/menu/updataMenu',
    method: 'post',
    data: Menu
  })
}

/**
 * 删除菜单
 * @param id
 */
export function deleteMenu(id) {
  return request({
    url: '/menu/deleteMenu',
    method: 'delete',
    params: {
      id
    }
  })
}

/**
 * 文件列表查询
 */
export const queryListPage = (current,size,FileVo) => {
  return request({
    url: '/queryListPage',
    method: 'post',
    params: {
      current,
      size
    },
    data : FileVo
  })
}

/**
 * 登录日志查询
 * @param current
 * @param size
 * @param queryKeyWord
 * @returns {AxiosPromise}
 */
export const getLoginLodList = (current,size,queryKeyWord) => {
  return request({
    url: '/loginlog/findLoginlogList',
    method: 'post',
    params: {
      current,
      size
    },
    data : queryKeyWord,
  })
}

/**
 * 删除登录日志
 * @param id
 * @returns {AxiosPromise}
 */
export function deleteLoginLog(id) {
  return request({
    url: '/loginlog/deleteById',
    method: 'delete',
    params: {
      id
    }
  })
}

/**
 * 操作日志查询
 * @param current
 * @param size
 * @param queryKeyWord
 * @returns {AxiosPromise}
 */
export const getLogList = (current,size,queryKeyWord) => {
  return request({
    url: '/log/queryLogList',
    method: 'post',
    params: {
      current,
      size
    },
    data : queryKeyWord,
  })
}

/**
 * 删除操作日志
 * @param id
 * @returns {AxiosPromise}
 */
export function deleteLog(id) {
  return request({
    url: '/log/delLogById',
    method: 'delete',
    params: {
      id
    }
  })
}

/**
 *  物资类别列表
 * @param UserKeyWord
 * @returns {AxiosPromise}
 */
export const findProductCategoryList = (UserKeyWord) => {
  return request({
    url: '/productCategory/findProductCategoryList',
    method: 'post',
    data : UserKeyWord
  })
}

/**
 * 物资类别详情
 * @param id
 * @returns {AxiosPromise}
 */
export function productCategoryDetail(id) {
  return request({
    url: '/productCategory/productCategoryDetail',
    method: 'post',
    params: {
      id
    }
  })
}

/**
 * 删除物资类别
 * @param id
 * @returns {AxiosPromise}
 */
export function deleteProductCategory(id) {
  return request({
    url: '/productCategory/deleteProductCategory',
    method: 'delete',
    params: {
      id
    }
  })
}

/**
 * 添加物资类别
 * @param ProductCategory
 * @returns {AxiosPromise}
 */
export const addProductCategory = (ProductCategory) => {
  return request({
    url: '/productCategory/addProductCategory',
    method: 'post',
    data : ProductCategory
  })
}

/**
 * 编辑物资类别
 * @param ProductCategory
 * @returns {AxiosPromise}
 */
export function updateProductCategory(ProductCategory) {
  return request({
    url: '/productCategory/updateProductCategory',
    method: 'post',
    data: ProductCategory
  })
}
